/*
通过题数 总罚时

若当前罚时线是0
则考虑理论最大罚时
每一个非 Accepted 且非 Compile Error 在该题的提交会对于该题增加 20 分钟罚时
总共15题，每题都在299分钟提交(在第300分钟开始后不能够再提交代码)，且交满了300min*30发提交,且最终只accept x+1发提交
299(x+1)+(9000-(x+1))*20
9000发提交中只有x+1通过
*/
#include <cstdio> 
#include <algorithm>
using namespace std;
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}

inline void write(long long x)
{
    if(x>=10) write(x/10);
    putchar(x%10+'0');
}
#define DEBUG
using PII=pair<int, int>;
#define accept first
#define time second
const int N=1e5+10;
int g, s, b, h, n;
PII score[N];

bool cmp(PII sc1, PII sc2)
{
    return sc1.accept!=sc2.accept?sc1.accept>sc2.accept:sc1.time<sc2.time;
}

void init()
{
    read(g), read(s), read(b), read(h);
    n=g+s+b+h;
    for(int i=1; i<=n; i++) read(score[i].accept), read(score[i].time); 
    sort(score+1, score+1+n, cmp);
}

void solve()
{
    init();
    // printf("sort:\n");
    // for(int i=1; i<=n; i++) 
    //     printf("%d %d\n", score[i].accept, score[i].time); 
    printf("%d %d %d %d\n", score[g].accept, score[g].time, score[g+1].time!=0?score[g+1].accept:score[g+1].accept+1, score[g+1].time!=0?score[g+1].time-1:180279+279*score[g+1].accept);
    printf("%d %d %d %d\n", score[g+s].accept, score[g+s].time, score[g+s+1].time!=0?score[g+s+1].accept:score[g+s+1].accept+1, score[g+s+1].time!=0?score[g+s+1].time-1:180279+279*score[g+s+1].accept);
    printf("%d %d %d %d\n", score[g+s+b].accept, score[g+s+b].time, score[g+s+b+1].time!=0?score[g+s+b+1].accept:score[g+s+b+1].accept+1, score[g+s+b+1].time!=0?score[g+s+b+1].time-1:180279+279*score[g+s+b+1].accept);

}

signed main()
{
    #ifdef DEBUG
        freopen("../in.txt", "r", stdin);
        freopen("../out.txt", "w", stdout);
    #endif

    int T=1; //scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}